package com.shop2cn.iapi.wxcomponent.testcase;

import java.util.HashMap;
import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.wxcomponent.parameter.GetPreAuthUrlBean;
import com.shop2cn.iapi.wxcomponent.service.GetPreAuthUrlCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.PayGateWayCallService;
import com.ymttest.database.sqlwapper.godmch.DefGodMchWapper;
import com.ymttest.utils.TestDataManager;
/**
*获取预授权页
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GetPreAuthUrl{
	private static GetPreAuthUrlBean getpreauthurlBean;
	private static GetPreAuthUrlCall getpreauthurlCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取预授权页");
	}

	@Before
	public void caseUp() {
		getpreauthurlBean=new GetPreAuthUrlBean();
		getpreauthurlCall=new GetPreAuthUrlCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getpreauthurlCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetPreAuthUrl_001() {
		Logger.start(true,"获取预授权页");
		try {
			Map m=new HashMap();
			m.put("mock", "mock-enable");
			m.put("mockId-1", TestDataManager.getRandomUUID().toString());
			m.put("mockApi-1", "wxcomponent-getPreAuthUrl-Normal");
			String code=TestDataManager.getRandomNum(6);
			m.put("mockParam-1-code",code);
			PayGateWayCallService.addMock(getpreauthurlCall, m);
			getpreauthurlCall.setData(getpreauthurlBean);
			getpreauthurlCall.callService();
			Logger.verifyEquals("200", getpreauthurlCall.getString("code"), "验证返回code");
//			new DefGodMchWapper().se
			//预授权 https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid=wxb2689299c456e19c&pre_auth_code=243736&auth_type=2
			Logger.verifyIsContains("https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid=wxb2689299c456e19c&pre_auth_code="+code+"&auth_type=2", getpreauthurlCall.getString("data"), "验证data");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}